<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <div class="box">
      <h2>简单计算器++++</h2>
      <div>数值1：<input type="text" v-model="num1" /></div>
      <div>数值2：<input type="text" v-model="num2" /></div>
      <div>
        <button @click="handle">计算</button>
      </div>
      <div>计算结果：<span v-text="result"></span></div>
      <div><button @click="cleardata">清除</button></div>
    </div>
    <script src="./js/vue.js"></script>
    <script>
      var vm = new Vue({
        el: ".box",
        data: {
          unm1: "",
          unm2: "",
          result: "",
        },
        methods: {
          handle() {
            this.result = parseInt(this.num1) + parseInt(this.num2);
          },
          cleardata() {
            this.result = "";
            this.num1 = "";
            this.m2 = "";
          },
        },
      });
    </script>
  </body>
</html>
